package com.cntcdt.api.db.dao;

import java.util.List;

import com.cntcdt.api.db.dao.base.DeviceExceptionDaoBase;
import com.cntcdt.api.db.model.DeviceExceptionModel;

/**
 * 这是cdt_device_exception的Dao实现类
 */
public class DeviceExceptionDao extends DeviceExceptionDaoBase   {
    /**
     * DeviceExceptionDao对象
     */
    private static DeviceExceptionDao instance = new DeviceExceptionDao();

    /**
     * 默认构造方法
     */
    private DeviceExceptionDao() {
    }

    /**
     * 获得对象实例
     */
    public static DeviceExceptionDao getInstance() { 
         return instance;
    } 
    
    public List<DeviceExceptionModel> findByTerminal(String terminal,int sortTime) {
    	sortTime = sortTime*20;
    	String sql = "SELECT * FROM " + TABLE + " WHERE terminal = ? order by addTime desc limit ?,20";
    	Object[] paramObjs = {terminal,sortTime};
    	List<DeviceExceptionModel > modelList = this.queryModelList(sql, paramObjs);
    	return modelList;
   }
    
    public List<DeviceExceptionModel> findByErrorPosition(String terminal) {
    	String sql = "SELECT * FROM " + TABLE + " WHERE terminal = ? and repairTime is NULL";
    	Object[] paramObjs = {terminal};
    	List<DeviceExceptionModel > modelList = this.queryModelList(sql, paramObjs);
    	return modelList;
   }

}
